package viewer;

import gamecontroler.GameState;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.example.boidpiranha.MainActivity;

import viewer.boid.BoidSprite;
import viewer.boid.BubbleButton;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import boidAlgorithms.interfaces.IBoid;

public class StandardGameView extends StandardViewScreen {

	private Bitmap piranha;

	private Iterator<IBoid> it;
	private List<IBoid> boidList;
	private List<BoidSprite> boidSprite;
	
	private List<BubbleButton> buttonList;

	public StandardGameView(GameState requirement, Resources resources,
			boolean isNavigation) {
		super(requirement, resources, isNavigation);
		createListOfBoid();
		createButtons();
	}

	public void drawOut(Canvas canvas) {
		 super.drawOut(canvas);
		 // drawButton(canvas);
		drawBoidSprite(canvas);
		int xt=gamecontroler.MainActivity.getTouchX();
		int yt=gamecontroler.MainActivity.getTouchY();
		canvas.drawText("(" + Integer.toString(xt)+":"+ 
		Integer.toString(yt)+")", xt, yt, new Paint(15));
		// drawSprite(canvas);
	}

	private void createListOfBoid() {

		boidList = stateRequirement.getBoidList();
		boidSprite = new ArrayList<BoidSprite>();
		it = boidList.iterator();

		int i = 0;
		while (it.hasNext()) {
			IBoid boid = it.next();
			String name = "boid" + Integer.toString(i);
			boidSprite.add(BoidSprite.gerBoidSprite(name, piranha, boid, 0f,
					1));
			i++;
		}
	}

	private void drawBoidSprite(Canvas canvas) {
		// TODO Auto-generated method stub
		for (int i = 0; i < boidList.size(); i++) {
			
			boidSprite.get(i).updateAndDraw(canvas, boidList.get(i));
		}
	}


	@Override
	protected void loadAllBitmap(Resources resources) {
		// TODO Auto-generated method stub
		background = bitmapColection.getBackground(resources);
		piranha = bitmapColection.getPiranha(resources);
	}

	@Override
	protected void loadAnimation() {
		// TODO Auto-generated method stub

	}

	@Override
	protected void createButtons() {
		// TODO Auto-generated method stub
		
	}

}
